package com.tuoyu.peopletest.utils;

import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.StyleSpan;

/**
 * UI,风格
 */
public class SCUIStyleUtils {
    /**
     * 改变颜色
     */
    public static SpannableString getChangeBold(String initStr,
                                               String change) {
        //int color = context.getResources().getColor(colorResId);

        if (TextUtils.isEmpty(initStr)) {
            initStr = "";
        }
        SpannableString ss = new SpannableString(initStr);

        int index = initStr.indexOf(change);

//        ss.setSpan(new ForegroundColorSpan(color),
//                index, index + change.length(),
//                Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        ss.setSpan(new StyleSpan(Typeface.BOLD),
                index, index + change.length(),
                Spanned.SPAN_INCLUSIVE_INCLUSIVE);
        return ss;
    }
}
